package com.handtransaction.dao;

import com.handtransaction.entity.Category;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface CategoryDao {
    //增加类别
    @Insert("INSERT INTO category VALUES (#{cid},#{cname})")
    int addCategory(@Param("cid") Integer cid, @Param("cname") String cname);

    //删除类别
    @Delete("delete from category where cid=#{cid}")
    int deleteCategory(Integer cid);

    //修改类别
    @Update("update category set cname=#{cname} where cid=#{cid}")
    int updateCategory(Category category);

    //通过cid查找类别
    @Select("select * from category where cid=#{cid}")
    Category querycategoryById(Integer cid);


    //通过类别名查找类别 --模糊查询
    @Select("select * from category where cname like '%' #{cname} '%' ")
    Category queryCategory(String cname);

    //查询全部类别
    @Select("select * from category")
    List<Category> queryAllCategory();



}
